<template>
	<view class="pageview">
		<view class="top-warp">
			<zx-nav title="评价订单"></zx-nav>
			<app-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></app-tabs>
		</view>
		<!-- top="xxx"下拉布局往下偏移,防止被悬浮菜单遮住 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :top="topH" @down="downCallback" @up="upCallback">
			<!-- 数据列表 -->
			<view class="list"><orderitem v-for="(item, index) in orderlist" :key="index" :orderinfo="item"></orderitem></view>
		</mescroll-body>
	</view>
</template>

<script>
import AppTabs from '@/components/app-tabs.vue';
import orderitem from '../components/orderitem.vue';
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
export default {
	mixins: [MescrollMixin],
	data() {
		return {
			tabIndex: 0,
			tabs: ['待评价', '已完成'],
			orderlist: []
		};
	},
	components: {
		AppTabs,
		orderitem
	},
	computed: {
		topH() {
			return this.CustomBar + uni.upx2px(100) + uni.upx2px(20) + 'px';
		}
	},

	methods: {
		tabChange(e) {
			this.mescroll.resetUpScroll();
		},
		upCallback(mescroll) {
			this.getevaluateList();
		},
		//获取售后订单列表
		getevaluateList() {
			let pageNum = this.mescroll.num; // 页码, 默认从1开始
			let pageSize = this.mescroll.size;
			let param = {
				page: pageNum,
				limit: pageSize,
				type: this.tabIndex == 0 ? '2' : '1'
			};
			let $me = this;
			this.$postAction(this.$api.getEvaluateList, param).then(da => {
				if (da.data && da.data.length > 0) {
					let curPageData = da.data;
					$me.mescroll.endBySize(curPageData.length, da.count);
					if ($me.mescroll.num == 1) $me.orderlist = []; //如果是第一页需手动制空列表
					$me.orderlist = $me.orderlist.concat(curPageData); //追加新数据
				} else {
					$me.orderlist = [];
					$me.mescroll.endSuccess(0, false);
				}
			});
		}
	}
};
</script>

<style lang="scss">
.top-warp {
	z-index: 9990;
	position: fixed;
	top: --window-top;
	/* css变量 */
	left: 0;
	width: 100%;
	background-color: white;
}

.list {
}
</style>
